//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//********************************************************* 

using Microsoft.TridentWordAddIn.Common;

namespace Microsoft.TridentWordAddIn.Presentation
{
    /// <summary>
    /// The base class for commands, especially from UI events of the Ribbon
    /// </summary>
    public abstract class RibbonCommand
    {
        /// <summary>
        /// holds controller reference
        /// </summary>
        private readonly IController controllerInstance;

        /// <summary>
        /// Initializes a new instance of the <see cref="RibbonCommand"/> class.
        /// </summary>
        /// <param name="controller">The controller.</param>
        protected RibbonCommand(IController controller)
        {
            this.controllerInstance = controller;
        }

        /// <summary>
        /// Gets a value indicating whether the originating control needs to be invalidated.
        /// </summary>
        /// <value><c>true</c> if the control needs to be invalidated; otherwise, <c>false</c>.</value>
        public virtual bool NeedsInvalidate
        {
            get
            {
                return false;
            }
        }

        /// <summary>
        /// Gets the controller instance.
        /// </summary>
        /// <value>The controller instance.</value>
        protected internal IController ControllerInstance
        {
            get { return this.controllerInstance; }
        }

        /// <summary>
        /// Invokes the command.
        /// </summary>
        /// <param name="controlId">The originating control id.</param>
        public abstract void Invoke(string controlId);

        /// <summary>
        /// Invokes the specified is pressed.
        /// </summary>
        /// <param name="isPressed">if set to <c>true</c> [is pressed].</param>
        public abstract void Invoke(bool isPressed);

        /// <summary>
        /// Shows the task pane.
        /// </summary>
        /// <param name="taskPaneKey">The task pane key.</param>
        /// <param name="isPressed">if set to <c>true</c> [is pressed].</param>
        protected virtual void ShowTaskPane(TaskPaneKey taskPaneKey, bool isPressed)
        {
            this.controllerInstance.ShowTaskPane(taskPaneKey, isPressed);
        }
    }
}
